<?php

namespace app\admin\controller;

use think\Controller;
use think\Request;

class Other extends Base
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        $list=db('other')->select();
        $this->assign('list',$list);
        return $this->fetch();
    }
    public function upload(){
        $file = request()->file('file');
        // 移动到框架应用根目录/public/uploads/ 目录下
        $info = $file->move('/upload/');
        if ($info) {
            $path = 'http://jiaoyu.com/'.'/upload/'.$info->getSaveName();
            return json(['code'=>0,'msg'=>'上传成功！','data'=>$path]);
        }else{
            return json(['code'=>1,'msg'=>'上传失败！','data'=>'']);
        }
    }
    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        $data        = input();
        $othermodel = model( 'other' );
        $list = $othermodel->edit($id,$data );
        if( $list) {
            $this->success( '修改成功');
        } else {
            $this->error( '修改失败' );
        }
    }
}
